<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2024/12/24 0024
  Time: 11:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>安全库存配置单复核子页面</title>
    <link rel="stylesheet"  href="/bootstrap/bootstrap-5.3.3-dist/css/bootstrap.min.css" />
    <link rel="stylesheet" href="/css/stock/b/safety_stock.css" />
    <style type="text/css">

    </style>
</head>
<body style="padding: 15px 50px;background-color: #eeeeee;">
<div class="panel-heading hhead">
    <nav aria-label="breadcrumb">
        <ol class="breadcrumb">
            <span style="color: blue;">您正在做的业务是：</span>
            <li class="breadcrumb-item"><a href="#">库存管理</a></li>
            <li class="breadcrumb-item"><a href="#">安全库存配置管理</a></li>
            <li class="breadcrumb-item active" aria-current="page">安全库存配置单复核</li>
        </ol>
    </nav>
</div>
<div style="margin-bottom: 2px">
    <div style="display: inline;margin-left: 84%;">
        <button class="btn btn-primary" id="btnOK">复核通过</button>
        <button class="btn btn-primary">返回</button>
    </div>
</div> <!-- 此div改用栅格来做 -->
<div id="designListBox">
    <div style="text-align: center">
        <h3>安全库存配置单</h3>
    </div>
    <div style="padding: 30px">
        <table class="tbl1">
            <tr>
                <td class="col1">配置单编号：</td>
                <td class="col2" id="storeId"></td>
            </tr>
            <tr>
                <td class="col1">产品名称：</td>
                <td class="col2" id="productName"></td>
                <td class="col1">产品编号：</td>
                <td class="col2" id="productId"></td>
            </tr>
            <tr>
                <td class="col1">库存报警上限数：</td>
                <td colspan="1">
                    <input type="text" class="txt_under_line" id="maxAmount">
                </td>
                <td class="col1">库存报警下限数：</td>
                <td colspan="2">
                    <input type="text" class="txt_under_line" id="minAmount">
                </td>
            </tr>
            <tr>
                <td class="col1">设计人：</td>
                <td colspan="2">
                    <input type="text" class="txt_under_line" id="register">
                </td>
            </tr>
        </table>

        <table class="table table-bordered" style="margin: 15px auto;">
            <thead>
            <tr>
                <th>序号</th><th>库房名称</th><th>存储地址编号</th>
                <th>存储地址名称</th><th>最大存储量</th>
            </tr>
            </thead>
            <tbody id="template" style="display: none">
                <tr>
                    <td id="serialNum"></td>
                    <td id="warehouseName"></td>
                    <td id="areaId"></td>
                    <td id="areaName"></td>
                    <td class="num"><input class="num-input" id="maxCapacityAmount"></td>
                </tr>
            </tbody>
            <tbody id="warehouseTbl">

            </tbody>

        </table>

        <table class="tbl3">
            <tr>
                <td class="col1">复核人：</td>
                <td class="col2"><input type="text" class="txt_under_line" id="checker"></td>
                <td class="col1">复核时间：</td> <td class="col2" id="time">系统时间</td>
            </tr>
            <tr>
                <td class="col1">配置要求：</td>
                <td colspan="3" style="padding-top: 5px">
                    <textarea rows="4" cols="100" id="config"></textarea>
                </td>
            </tr>
        </table>
    </div>
</div>

<script type="text/javascript" src="/js/jquery-3.7.0.min.js"></script>
<script type="text/javascript" src="/bootstrap/bootstrap-5.3.3-dist/js/bootstrap.bundle.min.js"></script>
<script type="text/javascript" src="/js/common.js"></script>
<script type="text/javascript">

    $(function () {
        //初始化页面
        initReview();

        updateDateTime();

        //初始化表格
        initwarehouseTbl();

        $("#btnOK").on("click",function () {
            alert("复核通过！");
            sessionStorage.setItem("checkTag",1);
        })
    })
    function initReview() {
        let id = sessionStorage.getItem("id");
        $.ajax({
            url: "/s-cell/initReviewTab?id="+id,
            type: "GET",
            dataType: "json",
            success: function (data) {
                console.log(data);
                if (data.errCode == "1") {
                    alert(data.errMsg)
                } else {
                    $("#storeId").text(data.storeId);
                    $("#productId").text(data.productId);
                    $("#productName").text(data.productName);
                    $("#maxAmount").val(data.maxAmount);
                    $("#minAmount").val(data.minAmount);
                    $("#register").val(data.register);
                    $("#checker").val(data.checker);
                    $("#time").text(data.registerTime);
                    $("#maxCapacityAmount").val(data.maxCapacityAmount);
                    $("#config").val(data.config);
                }
            }
        })
    }

    function initwarehouseTbl() {
        let id = sessionStorage.getItem("id");
        sessionStorage.clear();
        $.ajax({
            url: "/s-cell/initWarehouseTbl2?id=" + id,
            type: "get",
            datatype: "json",
            success: function (data) {
                console.log(data);
                $("#warehouseTbl").empty();
                let template = $("#template").children();

                let serialNum = 1;
                $.each(data,function (i,aa) {
                    let tr = template.clone();
                    $.each(aa,function (name,value) {
                        if(name == "ssecondProductArea"){
                            tr.find("#warehouseName").text(aa["ssecondProductArea"]["firstProductArea"]["swarehouseSetting"]["warehouseName"]);
                            let firstId=aa["ssecondProductArea"]["firstProductArea"]["firstId"];
                            let secondId=aa["ssecondProductArea"]["secondId"];
                            let thirdId=aa["thirdId"];
                            tr.find("#areaId").text(firstId + "-" + secondId + "-" +thirdId);

                            let firstName = aa["ssecondProductArea"]["firstProductArea"]["firstName"];
                            let secondName = aa["ssecondProductArea"]["secondName"];
                            let thirdName = aa["thirdName"];
                            tr.find("#areaName").text(firstName + "-" + secondName + "-" + thirdName);
                            $("#wareHoseId").val(aa["ssecondProductArea"]["firstProductArea"]["swarehouseSetting"]["warehouseId"]);

                        }
                    })
                    tr.find("#serialNum").text(serialNum++);
                    $("#warehouseTbl").append(tr);
                })
            }
        })
    }

    function updateDateTime(){
        let date = new Date();
        let year = date.getFullYear();
        let month = (date.getMonth() + 1).toString().padStart(2, '0');
        let day = date.getDate().toString().padStart(2,'0');
        let hours = date.getHours().toString().padStart(2,'0');
        let minutes = date.getMinutes().toString().padStart(2,'0');
        let seconds = date.getSeconds().toString().padStart(2,'0');
        let dateTimeStr = year+"-"+month+"-"+day+" "+hours+":"+minutes+":"+seconds;
        $("#time").text(dateTimeStr);
    }
</script>
</body>
</html>
